var offsetX:number;
var offsetY:number;

class MyGrid extends egret.DisplayObjectContainer{
    public constructor(){
        super();
        this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this)

        this.y = 100;
        
    }

    private onAddToStage(event:egret.Event) {
        var myGrid_01:GridSprite = new GridSprite();
        this.addChild( myGrid_01 );

        var myGrid_02:GridSprite = new GridSprite();  
        this.addChild( myGrid_02 );
        myGrid_02.x = 200;
        
        var txt:egret.TextField = new egret.TextField();
        txt.text = '哇啦啦啦啦完全恶趣味是否史蒂';
        txt.x = 10;
        txt.y = 20;
        this.addChildAt(txt, 1);

        var circle = new CircleMask();
        this.mask = circle;
        this.addChild(circle);
    }
}

class CircleMask extends egret.Shape {
    public constructor() {
        super();
        this.graphics.beginFill( 0xffffff * Math.random() );
        this.graphics.drawCircle(150, 50, 120);
        this.graphics.endFill();
    }
}

class GridSprite extends egret.Sprite
{
    public constructor()
    {
        super();
        this.drawGrid();
    }
    private drawGrid()
    {
        this.graphics.beginFill( 0x0000ff * Math.random() );
        this.graphics.drawRect( 0, 0, 50,50 );
        this.graphics.endFill();
        this.graphics.beginFill( 0x0000ff * Math.random() );
        this.graphics.drawRect( 50, 50, 50, 50);
        this.graphics.endFill();
        this.graphics.beginFill( 0xff0000 * Math.random() );
        this.graphics.drawRect( 50, 0, 50,50 );
        this.graphics.endFill();
        this.graphics.beginFill( 0xff0000 * Math.random());
        this.graphics.drawRect( 0, 50, 50,50 );
        this.graphics.endFill();
    }
}

